package com.ruoyi.customer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.customer.domain.ErpBusinessTripRecords;
import com.ruoyi.customer.service.IErpBusinessTripRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出差记录核销Controller
 * 
 * @author ruoyi
 * @date 2025-08-04
 */
@RestController
@RequestMapping("/customer/customer_records")
public class ErpBusinessTripRecordsController extends BaseController
{
    @Autowired
    private IErpBusinessTripRecordsService erpBusinessTripRecordsService;

    /**
     * 查询出差记录核销列表
     */
    @PreAuthorize("@ss.hasPermi('customer:customer_records:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpBusinessTripRecords erpBusinessTripRecords)
    {
        startPage();
        List<ErpBusinessTripRecords> list = erpBusinessTripRecordsService.selectErpBusinessTripRecordsList(erpBusinessTripRecords);
        return getDataTable(list);
    }

    /**
     * 导出出差记录核销列表
     */
    @PreAuthorize("@ss.hasPermi('customer:customer_records:export')")
    @Log(title = "出差记录核销", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpBusinessTripRecords erpBusinessTripRecords)
    {
        List<ErpBusinessTripRecords> list = erpBusinessTripRecordsService.selectErpBusinessTripRecordsList(erpBusinessTripRecords);
        ExcelUtil<ErpBusinessTripRecords> util = new ExcelUtil<ErpBusinessTripRecords>(ErpBusinessTripRecords.class);
        util.exportExcel(response, list, "出差记录核销数据");
    }

    /**
     * 获取出差记录核销详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:customer_records:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(erpBusinessTripRecordsService.selectErpBusinessTripRecordsById(id));
    }

    /**
     * 新增出差记录核销
     */
    @PreAuthorize("@ss.hasPermi('customer:customer_records:add')")
    @Log(title = "出差记录核销", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpBusinessTripRecords erpBusinessTripRecords)
    {
        return toAjax(erpBusinessTripRecordsService.insertErpBusinessTripRecords(erpBusinessTripRecords));
    }

    /**
     * 修改出差记录核销
     */
    @PreAuthorize("@ss.hasPermi('customer:customer_records:edit')")
    @Log(title = "出差记录核销", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpBusinessTripRecords erpBusinessTripRecords)
    {
        return toAjax(erpBusinessTripRecordsService.updateErpBusinessTripRecords(erpBusinessTripRecords));
    }

    /**
     * 删除出差记录核销
     */
    @PreAuthorize("@ss.hasPermi('customer:customer_records:remove')")
    @Log(title = "出差记录核销", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(erpBusinessTripRecordsService.deleteErpBusinessTripRecordsByIds(ids));
    }
}
